#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef struct node{
	int data;
	struct node *next;
};
void create(node *head,int size){
	node *t=head;
	int i;
	for(i=0;i<size;i++){
	node *newNode=(node *)malloc(sizeof(node));
	
	newNode->next=NULL;
	scanf("%d",&newNode->data);
   
    t->next=newNode;
    t=newNode;
    }

	
}
void trave(node *head){
	node *t=head->next;
	while(t != NULL){
		printf("%d ",t->data);
		t=t->next;
	}	
}
void deletSame(node *head){
	
	node *t=head->next;
	
	while(t != NULL){
		node *p1=t;
		node *p2=t->next;
		while(p2 != NULL){
			if(p1->data==p2->data){
				p1->next=p2->next;
				free(p2);
				p2=p1->next;
			}else{
				p1=p1->next;
				p2=p2->next;
			}
		}
		t=t->next;
	} 
	
}
void delet(node *head){
	node *t;
	int i=0;
	while(head->next != NULL){
		 t=head->next;
		 head->next=t->next;
		 free(t);
	}
}
void reverse(node *head){
	node *t;
	node *k=NULL;
	while(head->next != NULL){
		t=head->next;
		head->next=t->next;
		
		t->next=k;
		k=t;
	}
	head->next=t;
}
int main()
{
	node *head=(node *)malloc(sizeof(node));
	head->next=NULL;
	create(head,5);
	trave(head);
	deletSame(head);
	reverse(head);
	
	
	return 0;
}
